package com.eternalrights.mapper;

import org.apache.ibatis.annotations.*;
import com.eternalrights.pojo.Dept;

import java.util.List;

@Mapper
public interface DeptMapper {
    //方法一：Results注解
//    @Results({
//            @Result(column = "create_time", property = "createTime"),
//            @Result(column = "update_time", property = "updateTime")
//    })
//
//    @Select("SELECT id, name, create_time, update_time FROM dept")
//    public List<Dept> findAll();

    //方法二：起别名
//    @Select("SELECT id, name, create_time AS createTime, update_time AS updateTime FROM dept")
//    public List<Dept> findAll();

    //方法三：直接启用yml配置
    @Select("SELECT id, name, create_time, update_time FROM dept")
    public List<Dept> findAll();

    @Delete("DELETE FROM dept WHERE id = #{Inputid}")
    public void deleteById(Integer Inputid);

    @Insert("INSERT INTO dept(name, create_time, update_time) VALUES(#{name},#{createTime},#{updateTime})")
    public void insert(Dept dept);

    @Select("SELECT id, name, create_time, update_time FROM dept WHERE id = #{id}")
    public Dept getById(Integer id);

    @Update("UPDATE dept SET name = #{name},update_time = #{updateTime} WHERE id = #{id}")
    public void update(Dept dept);
}
